﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TestForFulentApi.EntityFramework;
using TestForFulentApi.Models;

namespace TestForFulentApi.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            EfContext ef = new EfContext();

            //var bb= ef.Blogs.Find(1);
            //return View();
          //  var b = new Blog() {BlogName ="blog1", Id =1};
            //ef.Blogs.Add(b);

         // Address a = new Address() { Location ="上海",Author =new Author() {Name ="hello"} };
         //   ef.Addresses.Add(a);
            //ef.SaveChanges();

           var author = new Author() { Name = "hell02",Address =new Address() {Location ="上海"} };
            ef.Authors.Add(author);

            var au = ef.Authors.Find(1);
            var k = au.Address;
            ef.Authors.Remove(au);
            ef.Addresses.Remove(k);
            ef.SaveChanges();


            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}